<template>
  <div class="wrap">
    <div class="header">
      <div class="left">
        <el-select v-model="queryParams.status" placeholder="请选择" @change="search">
          <el-option label="全部状态" value=""></el-option>
          <el-option label="已取消" :value="-1"></el-option>
          <el-option label="待支付" :value="0"></el-option>
          <el-option label="已支付" :value="1"></el-option>
        </el-select>
      </div>
      <div class="right">
        <div style="display: inline-block;margin-right: 20px;">
          <el-input size="small" style="width: 300px" v-model="queryParams.keyword" placeholder="搜索 1688订单、Mercado 订单、 快递单号"></el-input>
          <el-button size="small" type="primary" @click="search()">搜索</el-button>
        </div>
      </div>
    </div>
    <div class="content">
      <el-table
        v-loading="loading"
        :data="data"
        border
      >
        <el-table-column
          prop="procureNo"
          label="采购单号"
          align="center"
          min-width="200"
        >
          <template slot-scope="{row}">
            <diy-link>
              <span  @click="jumpInfo(row)">{{row.procureNo}}</span>
            </diy-link>
            <br>
            <el-tag type="danger" effect="dark" size="small" v-if="row.isModify === 1 && row.status === 0">订单变动</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="sumGoodsKindNum"
          label="采购商品（种）"
          align="center"
          min-width="150"
        >
          <template slot-scope="{row}">
            {{row.type !== 3 ? row.sumGoodsKindNum : '-'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="sumQuantity"
          label="采购商品（数）"
          align="center"
          min-width="150"
        >
          <template slot-scope="{row}">
            {{row.type !== 3 ? row.sumQuantity : '-'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="sumItemAmount"
          label="商品金额（元）"
          align="center"
          min-width="150"
        >
          <template slot-scope="{row}">
            {{row.type !== 3 ? row.sumItemAmount : '-'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="sumShippingFee"
          label="商品运费（元）"
          align="center"
          min-width="150"
        >
          <template slot-scope="{row}">
            {{row.type !== 3 ? row.sumShippingFee : '-'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="sumTotalAmount"
          label="总金额（元）"
          align="center"
          min-width="150"
        >
          <template slot-scope="{row}">
            {{row.type !== 3 ? row.sumTotalAmount : '-'}}
          </template>
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="制单时间"
          align="center"
          min-width="200"
        >
        </el-table-column>
        <el-table-column
          prop="statusStr"
          label="状态"
          align="center"
          min-width="150"
        >
        </el-table-column>
        <el-table-column
          prop="op"
          label="操作"
          align="center"
          min-width="200"
        >
          <template slot-scope="{row}">
            <diy-link @click="jumpInfo(row)">详情</diy-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="page-wrap">
        <el-pagination
          background
          layout="prev, pager, next"
          :current-page.sync="queryParams.page"
          :page-size="queryParams.pageSize"
          :total="count"
          @current-change="getData"
        >
        </el-pagination>
      </div>
    </div>

  </div>
</template>

<script>

import {stockList, suitStockGoods} from "@/api/stock";
import {deepCopy} from "@/utils";
import {getGoodsList} from "@/api/goods";
import ExportButton from "@/views/order/components/ExportButton.vue";
import {getProcureOrderList} from "@/api/procure";

export default {
  name: "procureOrderList",
  components: {

  },
  data(){
    return {
      loading: false,
      queryParams: {
        page: 1,
        pageSize: 10,
        keyword: '',
        status: '',
      },
      data:[],
      count: 0,
    }
  },
  created() {
    // this.setQueryParams()
    this.getData();
  },
  methods:{
    // 获取表单数据
    getData(){
      this.loading = true;
      getProcureOrderList(this.queryParams)
        .then(res=>{
          this.loading = false
          this.data = res.data
          this.count = res.info.count
        })
    },
    // 搜索表格数据
    search(){
      this.page = 1;
      this.getData()
    },
    // 跳转到采购详情
    jumpInfo(row){
      if(row.type === 3){
        this.$router.push({
          name: 'procureOrderPreviewOrder',
          query: {
            procureNo: row.procureNo,
          }
        })
      }else{
        this.$router.push({
          name: 'procureOrderInfo',
          query: {
            procureNo: row.procureNo,
          }
        })
      }

    }
  }
}
</script>

<style scoped lang="less">
.wrap {
  padding: 30px 30px;
  .header{
    display: flex;
    justify-content: space-between;
  }
  .content{
    padding: 20px 0 0;
  }
}

</style>

<style lang="less">
.channel-form{
  &.el-form{
    .el-form-item__label{
      word-break: break-word;
    }
  }
}
.channel-box-card{
  .el-card__header{
    padding: 5px 10px;
    font-size: 12px;
    line-height: 26px;
  }
  .el-card__body{
    padding: 0;
  }
}
.query-select{
  margin-right: 20px;
}
.select-goods-dialog{
  .footer{
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
  }
}
</style>
